package com.lagou.homework;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapTest {

    public static void main(String[] args) {

        Map<Student,String> m1 = new HashMap<>();

        m1.put(new Student("zhangfei",30),"海淀");
        m1.put(new Student("guanyu",35),"朝阳");
        m1.put(new Student("liubei",40),"昌平");
        // 遍历方式一：
        System.out.println(m1);

        System.out.println("----------------");
        Set<Student> s1 = m1.keySet();
        Collection<String> v1 = m1.values();
        //遍历方式二：
        for (Student ss: s1) {
            System.out.println(ss + "=" + m1.get(ss));
        }
        System.out.println("----------------");
        // 遍历方式三：
        for(String ss:v1) {
            System.out.println( ss);
        }
        System.out.println("----------------");
        // 遍历方式四：
        Set<Map.Entry<Student, String>> es = m1.entrySet();
        for (Map.Entry<Student, String> ss:es) {
            System.out.println(ss);
        }


    }
}
